<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div class="editor">
        <el-form label-position="left" size="mini" label-width="80px">
            <div v-if="showModuleEditor">
                <component :module="currentModule" :is="currentModule.name + '-editor'"></component>
            </div>
            <div v-if="showSubModuleEditor">
                <text-editor :module="currentSubModule" v-if="currentSubModule.name == 'text'"></text-editor>
            </div>
            <tabbar-editor v-if="showTabbarEditor"></tabbar-editor>
            <page-editor v-if="showPageEditor" />
        </el-form>
        <div class="footer"></div>
    </div>
</template>

<script>
import NewsEditor from "./editors/NewsEditor";
import ToursEditor from "./editors/ToursEditor";
import BannersEditor from "./editors/BannersEditor/Index";
import ImageEditor from './editors/ImageEditor/Index'
import VideoEditor from './editors/VideoEditor/Index'
import NavsEditor from "./editors/NavsEditor/Index";
import PostsEditor from "./editors/PostsEditor/Index";
import HousesEditor from "./editors/HousesEditor/Index"
import BrokersEditor from './editors/BrokersEditor/Index';
import PageEditor from "./editors/PageEditor";
import TextEditor from "./editors/TextEditor";
import SearchbarEditor from "./editors/SearchbarEditor";
import CustomModuleEditor from "./editors/CustomModuleEditor";
import NoticeEditor from "./editors/NoticeEditor";
import BlankEditor from "./editors/BlankEditor";
import FollowEditor from './editors/FollowEditor';
import ZhaofangEditor from './editors/ZhaofangEditor';
import WebviewEditor from "./editors/WebviewEditor.vue";
import TabbarEditor from "./editors/TabbarEditor/index.vue";
import VideosEditor from "./editors/VideosEditor.vue";
import MyselfloginEditor from "./editors/MyselfloginEditor.vue";
import BtnsEditor from "./editors/BtnsEditor/index.vue";
import HotnewsEditor from './editors/HotnewsEditor/index.vue';
import NewslistEditor from './editors/NewslistEditor/index.vue';
import BlockEditor from './editors/BlockEditor/index.vue';
import ScoregoodEditor from './editors/ScoregoodEditor/index.vue';
import SigndataEditor from './editors/SigndataEditor/index.vue';
import AuctionhousesEditor from './editors/AuctionHousesEditor/Index.vue'
import { mapGetters } from "vuex";

export default {
    components: {
        NoticeEditor,
        BlankEditor,
        NewsEditor,
        ToursEditor,
        NavsEditor,
        PostsEditor,
        HousesEditor,
        BrokersEditor,
        BannersEditor,
        PageEditor,
        ImageEditor,
        ZhaofangEditor,
        VideoEditor,
        TextEditor,
        NavsEditor,
        SearchbarEditor,
        FollowEditor,
        CustomModuleEditor,
        WebviewEditor,
        TabbarEditor,
        VideosEditor,
        MyselfloginEditor,
        BtnsEditor,
        HotnewsEditor,
        NewslistEditor,
        BlockEditor,
        ScoregoodEditor,
        SigndataEditor,
        AuctionhousesEditor,
    },

    props: {},

    methods: {},

    computed: {
        ...mapGetters(["pagemaker"]),
        focus: function () {
            return this.$store.state.pagemaker.focus;
        },

        showSubModuleEditor: function () {
            return this.focus == "subModule";
        },
        showPageEditor: function () {
            // 判断是否显示页面编辑器
            return this.focus == "page";
        },
        showTabbarEditor: function () {
            // 判断是否显示tabbar编辑器
            return this.focus == "tabbar";
        },
        showModuleEditor: function () {
            return this.focus == "module" && this.currentModule;
        },
        saveBtnEnable: function () {
            return true;
            // 保存按钮有效的情况
            if (this.configChangedMark == 0 && this.modulesChangedMark == 0) {
                return false;
            }
            return true;
        },

        currentSubModule: function () {
            // todo
        },

        currentModule: {
            get () {
                console.log("update current moduel ", this.$store.state.pagemaker.currentModule);
                return this.$store.state.pagemaker.currentModule;
            },
            set (val) {
                console.log("update current moduel ");
                this.$store.commit("pagemaker/UPDATE_MODULE", val);
            },
        },
    },
    data () {
        return {
            configChangedMark: 0,
            modulesChangedMark: 0,
            loading: false,
        };
    },
};
</script>

<style scoped>
.editor {
    box-sizing: border-box;
    position: relative;
    height: 100%;
}

.editor form {
    padding: 15px 40px;
}

/* .editor .header {
} */

/* .editor .btns {
} */

.editor .header .publish {
    background: #1989fa;
    color: #fff;
}

.editor .header .reset {
    background: none;
    color: #333;
}

</style>